package com.jxy.bean.attribute;

import com.jxy.bean.ClassFile;
import com.jxy.tool.Tool;

import java.io.DataInputStream;

public class AttibuteCodeExceptionInfo {
    private int start_pc;
    private int end_pc;
    private int handler_pc;
    private int catch_type;

    private ClassFile cf;

    public AttibuteCodeExceptionInfo(DataInputStream dis, ClassFile cf) {
        start_pc = Tool.readU2(dis);
        end_pc = Tool.readU2(dis);
        handler_pc = Tool.readU2(dis);
        catch_type = Tool.readU2(dis);
        this.cf = cf;
    }

    @Override
    public String toString() {
        return "ExceptionInfo{" +
                "start_pc=" + start_pc +
                ", end_pc=" + end_pc +
                ", handler_pc=" + handler_pc +
                ", catch_type=" + cf.getPools()[catch_type] +
                '}';
    }
}
